<template>
  <div id="app">
    <div id="nav">
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>|
      <router-link to="/user/202101">user</router-link>|
      <router-link to="/info">info</router-link>|
      <router-link to="/login">login</router-link>
      <hr>
      <div>
          <!-- 通过query进行传参 -->
          <router-link :to="{path:'info',query:{name:'rh',age:22,sex:'男'}}">info-path</router-link>
          <!-- 编程式导航 -->
          <button @click="toinfo">info</button>
          <!-- 编程式导航 -->
          <button @click="toHome">about</button>
      </div>
     
    </div>
    <router-view/>
  </div>
</template>
<script>
  export default{
    data(){
      return{
        userid:'202102'
      }
    },
    methods: {
      toHome(){
          this.$router.push({path:'/about',params:{userid:'22222'}})//以对象的方式进行跳转
      },
      toinfo(){
        this.$router.replace({name:'info',params:{name:'追梦',age:22,sex:'女'}})
      }
    }
  }
</script>


<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;
}

#nav a {
  font-weight: bold;
  color: #2c3e50;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
</style>
